約 2,055,417 件
https://w.atwiki.jp/nina_a/pages/61.html
テンプレート(Templates) このページを編集 概要 すべてのWPFコントロールは"見た目"を持たないように設計されている.ただし,既定の見た目を持っており,これからVisualTreeが作成される.この見た目を決めるものがコントロールテンプレートと呼ばれるものであり,XAMLで定義されている. コントロールの標準のテンプレートを表示する このプログラムは Matthew MacDonald:Pro WPF in C# 2010 Windows Presentation Foundation in .Net 4 に掲載されているものをもとに作成した. +コントロールの標準のテンプレートを表示するサンプルプログラム XAML Window x Class="WpfSampleApplication.MainWindow" xmlns="http //schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns x="http //schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="600" Width="1000" Loaded="Window_Loaded" StackPanel Orientation="Horizontal" Name="layoutRoot" TreeView Name="lstTypes" SelectedItemChanged="lstTypes_SelectedItemChanged" Width="400"/ TextBox Name="txtTemplate" Width="600" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"/ /StackPanel /Window C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Globalization; using System.Reflection; using System.Xml; using System.Windows.Markup; namespace WpfSampleApplication { /// summary /// MainWindow.xaml の相互作用ロジック /// /summary public partial class MainWindow Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { Type controlType = typeof(Control); List Type derivedTypes = new List Type (); // Search all the types in the assembly where the Control class is defined. Assembly assembly = Assembly.GetAssembly(typeof(Control)); foreach (Type type in assembly.GetTypes()) { // Only add a type of the list if it s a Control, a concrete class, // and public. if (type.IsSubclassOf(controlType) !type.IsAbstract type.IsPublic) { derivedTypes.Add(type); } } // Sort the types. The custom TypeComparer class orders types // alphabetically by type name. derivedTypes.Sort(new AlphabeticalComparer()); // Show the list of types. lstTypes.ItemsSource = derivedTypes; } private void lstTypes_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs object e) { try { // Get the selected type. Type type = (Type)lstTypes.SelectedItem; // Instantiate the type. ConstructorInfo info = type.GetConstructor(System.Type.EmptyTypes); Control control = (Control)info.Invoke(null); // Add it to the grid (but keep it hidden). control.Visibility = Visibility.Collapsed; layoutRoot.Children.Add(control); // Get the template. ControlTemplate template = control.Template; // Get the XAML for the template. XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; StringBuilder sb = new StringBuilder(); XmlWriter writer = XmlWriter.Create(sb, settings); XamlWriter.Save(template, writer); // Display the template. txtTemplate.Text = sb.ToString(); // Remove the control from the grid. layoutRoot.Children.Remove(control); } catch (Exception err) { txtTemplate.Text = " テンプレートの生成に失敗しました。 " + err.Message + " "; } } private class AlphabeticalComparer IComparer Type { public int Compare(Type x, Type y) { return string.Compare(x.FullName, y.FullName); } } } } カテゴリ:WPF 名前
https://w.atwiki.jp/nina_a/pages/57.html
アニメーション このページを編集 概要 WPFでは,マージンなどの見た目に関わるプロパティの値を順次変化させることでアニメーションを実現する. XxxAnimationクラス WPFには時間の経過に応じて値を変化させるXxxAnimationクラスが用意されている.Xxxには変化させる値のタイプが入り,double型を変化させる場合にはDoubleAnimationクラスを利用する. +DoubleAnimationサンプル Window x Class="WpfSampleApplication.MainWindow" xmlns="http //schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns x="http //schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" StackPanel Button Width="200" Height="100" アニメーションテスト Button.Triggers EventTrigger RoutedEvent="MouseEnter" BeginStoryboard Storyboard DoubleAnimation To="300" Duration="0 0 2" Storyboard.TargetProperty="(Button.Width)" / /Storyboard /BeginStoryboard /EventTrigger EventTrigger RoutedEvent="MouseLeave" BeginStoryboard Storyboard DoubleAnimation To="200" Duration="0 0 2" Storyboard.TargetProperty="(Button.Width)" / /Storyboard /BeginStoryboard /EventTrigger /Button.Triggers /Button /StackPanel /Window 主な依存プロパティ From アニメーションの開始値.指定しない場合は現在の値. To アニメーションの終了値.指定しない場合は既定の(オリジナルの)値. By アニメーションの変量.From+By=To.ToとByの両方が指定された場合はToが優先. Duration アニメーションの時間.Duration.Foreverで永遠に続く(無限大の時間の)アニメーション.Foreverを指定すると,無限大の時間をかけてFromからTo,Byまでアニメーションするため,変化しているように見えない.無限回続くアニメーションの意味ならばRepeatBehaviorにRepeatBehavior.Foreverをセットする. 主なプロパティ AccelerationRatio Dulationの内,加速に使う時間の割合.DecelerationRatioとの和が1を超えてはいけない. AutoReverse trueなら,アニメーション終了後,逆再生する FillBehavior アニメーション終了時の動作指定.既定は保留(アニメーション終了時の値を維持).Stopを指定すると終了(アニメーション終了時の値を破棄)する. DecelerationRatio Dulationの内,減速に使う時間の割合.AccelerationRatioとの和が1を超えてはいけない. RepeatBehavior アニメーションの繰り返し動作指定.既定は1回実行.回数や実行時間で指定. SpeedRatio アニメーションの速度.5を指定すれば5倍の早さ. ストーリーボード(Storyboard) アニメーションの対象(TargetNameとTargetProperty)をStoryboardで指定する.複数XxxAnimationを記述すれば,それらを同時実行できる. +Storyboardサンプル Storyboard DoubleAnimation To="300" Duration="0 0 2" AccelerationRatio="0.2" DecelerationRatio="0.2" Storyboard.TargetProperty="(Button.Width)" / DoubleAnimation To="300" Duration="0 0 2" AccelerationRatio="0.2" DecelerationRatio="0.2" Storyboard.TargetProperty="(Button.Height)" / /Storyboard この例ではTargetPropertyを各アニメーションごとに指定しており,TargetNameは指定していない. アニメーションを制御する 止めたり,リスタートしたり.それぞれのボタンのトリガーでPauseStoryBoardとかやってもBeginStoryBoardが見つからないので止まらない.なのでその親要素のStackPanelでまとめて記述.他の操作は MSDN 参照.再生速度とかもっと細かい制御はXAMLでは無理. +アニメーション制御サンプル Window x Class="WpfSampleApplication.MainWindow" xmlns="http //schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns x="http //schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="400" Width="500" Grid Grid.RowDefinitions RowDefinition Height="*" / RowDefinition Height="Auto" / /Grid.RowDefinitions Button Width="200" Height="100" Name="dest" Grid.Row="0" アニメーションテスト /Button StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center" Button Width="100" Margin="5" Content="開始" Name="start" / Button Width="100" Margin="5" Content="停止" Name="pause" / Button Width="100" Margin="5" Content="再開" Name="resume" / Button Width="100" Margin="5" Content="終了" Name="stop" / StackPanel.Triggers EventTrigger RoutedEvent="Button.Click" SourceName="start" BeginStoryboard x Name="animation" Storyboard Storyboard.TargetName="dest" DoubleAnimation To="300" Storyboard.TargetProperty="(Button.Width)" FillBehavior="Stop" Duration="0 0 15"/ DoubleAnimation To="300" Storyboard.TargetProperty="(Button.Height)" FillBehavior="Stop" Duration="0 0 15"/ /Storyboard /BeginStoryboard /EventTrigger EventTrigger RoutedEvent="Button.Click" SourceName="pause" PauseStoryboard BeginStoryboardName="animation"/ /EventTrigger EventTrigger RoutedEvent="Button.Click" SourceName="resume" ResumeStoryboard BeginStoryboardName="animation"/ /EventTrigger EventTrigger RoutedEvent="Button.Click" SourceName="stop" StopStoryboard BeginStoryboardName="animation"/ /EventTrigger /StackPanel.Triggers /StackPanel /Grid /Window イージング(Easing) イージングを使うと値の変化の仕方を変えることができる.全てのEasingFunctionについては MSDN 参照. +イージング関数にPowerEaseを指定するサンプル DoubleAnimation To="300" Storyboard.TargetProperty="(Button.Width)" Duration="0 0 2" DoubleAnimation.EasingFunction PowerEase EasingMode="EaseInOut" Power="2" / /DoubleAnimation.EasingFunction /DoubleAnimation すべてのEasingFunctionはEasingModeというプロパティを持っている. EaseIn アニメーション開始付近でイージングする EaseOut アニメーション終了付近でイージングする EaseInOut アニメーション開始と終了付近の両方でイージングする キーフレーム指定によるアニメーション XxxAnimationの変わりにXxxAnimationUsingKeyFrameを使うと,指定の時刻(キーフレーム)における値を指定することでアニメーションを実現できる. +キーフレーム指定によるアニメーション DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Button.Width)" LinearDoubleKeyFrame Value="300" KeyTime="0 0 1"/ DiscreteDoubleKeyFrame Value="200" KeyTime="0 0 2" / SplineDoubleKeyFrame Value="100" KeyTime="0 0 3" / EasingDoubleKeyFrame Value="300" KeyTime="0 0 4" EasingDoubleKeyFrame.EasingFunction BounceEase / /EasingDoubleKeyFrame.EasingFunction /EasingDoubleKeyFrame /DoubleAnimationUsingKeyFrames キーフレームを指定するときにはYyyXxxKeyFrameを使う.Yyyにはそのキーフレームまでの値の変化の仕方が入り,Linear(直線),Discrete(不連続),Spline(スプライン),Easing(指定のイージング関数)の4種類. このサンプルでは,1秒経過まで直線的に300まで変化し,2秒経過した瞬間に200に変化,3秒経過までスプライン曲線を描いて100まで変化,その後EasingFunctionに指定されたBounceEaseを使って300まで変化する. カテゴリ:WPF 名前
https://w.atwiki.jp/playstationhome/pages/1114.html
▽メーカー一覧CapcomCodeglue B.V.Electronic ArtsElectronic Entertainment Expo 2011Electronic Entertainment Expo 2012FromSoftwareGranzellaHellfire GamesHudson SoftIREM SOFTWARE ENGINEERINGLIAR GAMELockwood PublishingLOOT™Mass Media GamesNAMCO BANDAI GamesnDreamsNIPPON ICHI SOFTWAREO-TwoPlayStation®HomeQ-GamesRed BullSCEJSONYSony Computer EntertainmentSPE-WPFSQUARE ENIXTECMO KOEI GAMESUbisoftWill日本コカ・コーラ照英王国-----▽ラウンジ一覧▼プライベートラウンジパーソナルスペース一覧クラブハウス一覧▼パブリックラウンジ常設ラウンジ(Homeラウンジ)一覧特設ラウンジ一覧▼グローバルラウンジグローバルラウンジ一覧 目次 SPE-WPF Inc.URL公式サイト Facebook Twitter ラウンジパーソナルスペース クラブハウス 常設ラウンジ 特設ラウンジグローバルラウンジ インタラクティブアイテムゲーム オブジェクト イベント 内容 SPE-WPF Inc. URL 公式サイト http // Facebook http // Twitter http // ラウンジ パーソナルスペース クラブハウス 常設ラウンジ 特設ラウンジ グローバルラウンジ インタラクティブアイテム ゲーム オブジェクト イベント コメント欄 ※掲載情報に関するコメントはこちらへどうぞ(スパム防止のため、URLの投稿は禁止しています)。 ※Wiki編集方法が分からない方は、こちらか情報提供板へ情報をお寄せください。文章体で書き込んで頂けると、Wikiへの反映もはやくなるかと思います。 ※攻略等の質問は質問掲示板へどうぞ。 名前 コメント すべてのコメントを見る
https://w.atwiki.jp/atachi/pages/30.html
コマンドの呼び出し [#o999e49e] コマンドの対象 [#zf5396dd] コマンドの『中身』の実装 [#f2e1a4a6] カスタムコマンドの作成 [#b4d9c788] ICommandを使用したコマンドクラスの実装 [#l2907103] コマンドソースの作成 [#xa070e5b] コマンドを利用することで、コマンドが設定されたコンポーネントの意味とコマンドが実際に行うロジックとの関係が切り離される。 右クリックメニューの「切り取り」「コピー」「貼り付け」はコマンドの代表例である。それぞれの意味は誰しも知っているが、各コマンドがどのような処理を行うかは各アプリケーションが実装しなければならない。 WPFのコマンドもこのような意味であると捉えることができる。 MSDN コマンド実行の概要 WPF コマンド コマンドとは実行されるアクションで、ICommandを継承しアクションを実装します。 コマンドの呼び出しは、コマンドソースから行います。 コマンドソースとはコマンドを呼び出す対象の要素です。ICommandSource を実装したクラスです。 WFPではButtonクラスやMenuItemクラスが実装済みです。 コマンドターゲットとはコマンドを実行する対象の要素です。 コマンドの呼び出し ボタンが押された時にコマンドを呼び出したい場合は、Button.Commandに呼び出したいコマンドを指定します。 Button Command="ApplicationCommands.Open" Image Source="images/FileOpen.png" /Image /Button Button Command="ApplicationCommands.Open" CommandParameter="パラメータ" Image Source="images/FileOpen.png" /Image /Button CommandParameter属性はコマンドのハンドラに渡されるパラメータです。 ICommand.Execute の引数にそのまま渡されます。 コード上からコマンドを呼び出したい場合は、Execute()をコールします。 ApplicationCommands.Paste.Execute(null,textbox1); コマンドの対象 発行されたコマンドを受け取り、コマンドを実行する要素を対象と呼びます。 次の例ではメニューバーから「貼り付け(ApplicationCommands.Paste)」というコマンドを発行した場合に、そのコマンドの実行対象としてmainTextBoxを指定しています。 StackPanel Menu MenuItem Command="ApplicationCommands.Paste" CommandTarget="{Binding ElementName=mainTextBox}" / /Menu TextBox Name="mainTextBox"/ /StackPanel コマンドの『中身』の実装 Windowsアプリケーションでよく使用される「保存」というコマンドは、その意味は誰でも知っているが、何をどのように保存するかはアプリケーションによって異なる。 テキストエディタならばファイルに文字列を保存する事を指しますし、ペインタなどのグラフィックソフトならばビットマップを任意の画像形式で保存します。 このようにコマンドがどのような処理を行うかは、アプリケーション側で実装する必要があります。 あるコマンドを受け取ったときの処理を結びつけることをコマンドバインディングと呼びます。 コマンドバインディングは分離コード、またはXAMLに記述することができます。 コマンドバインディングをコードで実装する場合は、CommandBindingを使用します。 public partical class MainWindow Window { public MainWindow() { InitializeComponent(); // コマンドバインディングの定義 CommandBinding cb = new CommandBinding(); cb.Command = ApplicationCommands.Open; // バインドしたいコマンドの種類 cb.Executed += new ExecutedRoutedEventHandler(onOpenExecuter); this.CommandBinding.Add( cb ); } private void onOpenExecuter(object sender, ExecutedRoutedEventArgs e) { } } また、このコードの等価実装をXAMLで記述することもできます。 Window Window.CommandBindings CommandBinding Command="ApplicationCommands.Open" Execute="onOpenExecuter" / /Window.CommandBindings /Window カスタムコマンドの作成 オリジナルのコマンドを実装したい場合、RoutedCommand または RoutedUICommand の静的なインスタンスを定義します。 static RoutedUICommand StartUp = new RoutedUICommand( "アプリケーションのスタートアップ", "StartUpCommand", typeof(MainWindow)); ICommandを使用したコマンドクラスの実装 namespace my { // コマンドが実行された場合に、任意の処理(アクション)を呼び出す public class RelayCommand ICommand { private readonly Action _execute; private readonly Func bool _canExecute; public RelayCommand(Action execute, Func bool canExecute) { _execute = execute; _canExecute = canExecute; } // ICommand Members public bool CanExecute(object parameter) { // コマンドが実行可能か?? // _canExecuteが設定されている場合は、_canExecuteを使用するが、 // 設定されていない場合は常に「true」とする。 // return _canExecute == null ? true _canExecute(); } // ICommand Members public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } // ICommand Members public void Execute(object parameter) { // コマンド実行時の処理 _execute(); } } } コマンドソースの作成 コマンドソースとはコマンドを発行できるオブジェクト要素です。 C#コードを使えばコマンドは自由に発行できるのですが、XAMLからコマンドを発行したい場合はオブジェクト要素がコマンドソースとなるように実装しなければなりません。 コマンドソースとなるには ICommandSource を継承したオブジェクト要素を作成します。 ButtonクラスはICommandSourceを継承しているので、ICommandSource.CommandによってButtonがクリックされたときに発行するコマンドを指定します。 コマンドソースを実装する場合、ICommandが発行するCanExecuteChangedイベントをハンドリングします。 CanExecuteChangedはICommandが実行可能である場合にtrueを取得できるイベントで、コマンドが発行可能であるかユーザーに知らせることができます。
https://w.atwiki.jp/atachi/pages/52.html
依存関係プロパティの基本実装 [#xa682a33] 依存関係プロパティの識別子を実装 [#i7e417dd] FrameworkPropertyMetadataで指定するメタデータについて [#a3e9a582] コレクションの依存関係プロパティ [#a4489562] 参考サイト コントロールを自作する場合に、コントロールが公開するプロパティは依存関係プロパティとして実装します。 依存関係プロパティとして実装すると、バインディングが使えるようになります。 リソース データ バインディング スタイル Animations メタデータのオーバーライド プロパティ値の継承 WPF デザイナーの統合 依存関係プロパティの基本実装 依存関係プロパティは次のようにDependencyPropertyを使用して値を管理します。 値の取得や設定はすべてGetValueメソッド/SetValueメソッドで行われます。 コントロールを使う側は、公開されているプロパティである依存関係プロパティだけしか見えません。 class MyCustomControl Control { // 依存関係プロパティの識別子 public static readonly DependencyProperty IsSpinningProperty = DependencyProperty.Register( "IsSpinning", // name 引数 typeof(Boolean), // propertyType 引数 typeof(MyCustomControl), // ownerType 引数 ); // 依存関係プロパティ public bool IsSpinning { get { return (bool)GetValue(IsSpinningProperty); } set { SetValue(IsSpinningProperty, value); } } } 依存関係プロパティの識別子を実装 DependencyProperty.Register()を使用して、 WPFが持つプロパティシステムにプロパティに関する情報を登録します。 引数名 設定内容例 説明 name "IsSpinning" プロパティシステムに登録するプロパティ名。 propertyType typeof(Boolean) プロパティの型情報。typeofを使って型情報を取り出す。 ownerType typeof(MyCustomControl) プロパティを定義したクラスの型情報。 typeMetadata new FrameworkPropertyMetadata(...) プロパティについての追加情報。FrameworkPropertyMetadata を使って指定する。省略可能。こちら validateValueCallback new ValidateValueCallback(...) プロパティの値についてのバリデーション。ValidateValueCallback を使って指定する。省略可能。 Registerの戻り値には依存関係プロパティに関する情報が含まれている。 依存関係プロパティに値を設定する場合や取得する場合はこのインスタンスをつかって行う。 このインスタンスは、public static readonlyで定義する必要がある。 FrameworkPropertyMetadataで指定するメタデータについて FrameworkPropertyMetadata を使用すると、プロパティに関する設定が行える。 プロパティの初期値 プロパティ変更時に呼び出されるコールバックメソッド WPFデザイナによるデザイン時の挙動 デフォルトのデータバインディングのモード VisualObjectツリーで親から子へのプロパティ継承 WPFデザイナに関係するプロパティがいくつかあります。 適切に設定することで、WPFデザイナ使用時のパフォーマンスがよくなります。 AffectsMeasureプロパティ値の変更時に、サイズ変更を伴うコントロールの再描画が必要。 AffectsArrangeプロパティ値の変更時に、サイズ変更を伴わない(自分より下階層のサイズ変更は許可)コントロールの再描画が必要。 AffectsRenderプロパティ値の変更時に、一切のサイズ変更が伴われないコントロールの再描画が必要。 コレクションの依存関係プロパティ カスタムコントロールのコンストラクタでSetValueを使ってsingletonなコレクション型インスタンスを作成する 依存関係プロパティ識別子は読み取り専用で登録する(DependencyProperty.RegisterReadOnly を使用する) class MyCustomControl Control { public MyCustomControl() base() { SetValue(ItemsPropertyKey, new List FrameworkElement () ); } private static readonly DependencyPropertyKey ItemsPropertyKey = DependencyProperty.RegisterReadOnly( "Items", typeof(List FrameworkElement ), typeof(MyCustomControl), new FrameworkPropertyMetadata(new List FrameworkElement ()) ); // 依存関係プロパティの識別子 public static readonly DependencyProperty IsSpinningProperty = DependencyProperty.Register( "IsSpinning", // name 引数 typeof(Boolean), // propertyType 引数 typeof(MyCustomControl), // ownerType 引数 ); public static readonly DependencyProperty ItemsProperty = ItemsPropertyKey.DependencyProperty; // 依存関係プロパティ public bool IsSpinning { get { return (bool)GetValue(IsSpinningProperty); } set { SetValue(IsSpinningProperty, value); } } public List FrameworkElement Items { get { return (List FrameworkElement )GetValue(ItemsProperty); } } } 参考サイト MSDN カスタム依存関係プロパティ
https://w.atwiki.jp/eamat/pages/17.html
- IME制御用 関数群 (IME.ahk) AutoHotkey上で日本語入力の制御を可能にするための関数群、IMM32 API使用 AutoHotkey_L (A32/U32/U64)に対応しました。 ダウンロード IME20121110.zip (本家,A32/U32/U64 同梱) 旧バージョンはこのへん 内容 説明書 IME.txt ソース IME.ahk 使用方法 ・#Includeで組み込む ・Libフォルダにコピーして関数ライブラリスクリプトとして ・必要部分だけコピペで切り出す、等 関数一覧 IME_GET( ) IMEのON/OFF 状態の取得 IME_SET( ) IMEのON/OFF 状態の制御 IME_GetConvMode( ) IME 入力モードの取得 (あアアAA) IME_SetConvMode( ) IME 入力モードの制御 IME_GetSentenceMode( ) IME 変換モードの取得(人名/一般/話し言葉など) IME_SetSentenceMode( ) IME 変換モードの制御 IME_GetConverting( ) IME 文字入力の状態を返す(入力・変換中/変換候補ウィンドウ表示中 など) 更新履歴 2012.11.10 |・AutoHotkey_L (A32/U32/U64)対応 ・WinTitleパラメータが実質無意味化していたのを修正 ・スクリプトのファイル形式をUTF-8(BOM付)に変更 2009.12.03 |・IME 状態チェック GUIThreadInfo 利用版 入れ込み IEや秀丸8βでIME状態が取れなかったのを対応した 参考:http //blechmusik.xrea.jp/resources/keyboard_layout/DvorakJ/inc/IME.ahk ・Google日本語入力β 向け調整 入力モード 及び 変換モードは取れないっぽい IME_GET/SET() と IME_GetConverting()は有効 2009.07.02 |・AutoHotkey スレッド part8 99にあった IME_IsConverting() をパクって追加 http //pc12.2ch.net/test/read.cgi/software/1243005818/99-105 99 名前:名無しさん@お腹いっぱい。[sage] 投稿日:2009/06/02(火) 対象窓で、文字入力中or変換中なら1を、変換候補窓が出ているなら2を、 それ以外なら 0を返す。 ATOK2007とMS-IME8.1で確認。クラス名がバージョンの数値違いだけなら 別verでも通用するかも。 ・パラメータのWinTitleの既定値を アクティブウィンドウにしたはいいが、 何故だか妙に回りくどいことをやっていて、Last Found Window (http //lukewarm.s101.xrea.com/Window.html#lastfoundwindow) が有効にならない仕様になってたのを修正 ・DllCallだと隠しウィンドウでも操作可能なようなので AHK内蔵のSendMessageコマンド → DllCall("SendMessaege")に。 DetectHiddenWindowsのOn/Off廃止
https://w.atwiki.jp/atachi/pages/34.html
コンテナ コンテナクラス 説明 Grid コンテナを任意の数のグリッドに区切る。各グリッド内を境界としてコンポーネントを配置したり、複数のグリッドをまたぐこともできる。 StackPanel コンポーネントを任意の方向に向けて一列に並べる。「上下方向」か「左右方向」の指定はOrientation属性で指定する。表示はFlexのHBoxやVBoxのようになる(または、Directionを指定したBox)。 WrapPanel コンポーネントを左上から右下に向けて連続して並べる。並べる際の方向は左から右方向か、上から下方向で選択できる。 Canvas 座標を指定できるので、コンポーネントを自由な場所に配置できる。 マウスイベントの問題 DaDMgrはアプリケーションのルート要素が受け取っているPreviewDragOverイベントをハンドリングし、Adornerをマウスに追従させているのですが、背景色を設定しないコンテナにおいて、マウスイベントが発生しない問題があります。(WPFでは予てからのバグなのか仕様なのか・・・) ただし、この問題は簡単に回避可能で、Backgroundプロパティを設定すればよいだけです。 透過色も使用できます。 Window Grid Grid.Background SolidColorBrush / /Grid.Background /Grid /Window
https://w.atwiki.jp/kimetsunoyaiba/pages/55.html
IME辞書 以下の文章をコピペして辞書登録してください。 禰豆子 ねずこ 鬼滅の刃 鬼滅の刃IME辞書 鋼鐵塚 はがねづか 鬼滅の刃 鬼滅の刃IME辞書
https://w.atwiki.jp/fumiduki1985/pages/341.html
WPFアプリケーションのエントリーポイントとなるMain()関数は、App.xaml(デフォルトの名前。変更した場合はこれに限らない。)をビルドした際に自動実装され、普段プログラマが実装することはない。 しかし、Main関数を自前で実装したい場合は、App.xamlのプロパティで「ビルドアクション」を「Page」に変更すればよい。 こうすることで、Main関数が自動実装されなくなり、独自のMain関数を実装可能になる。 このページのタグ一覧 C# WPF プログラミング 最終更新日:2018/02/06
https://w.atwiki.jp/atachi/pages/31.html
スタイルの使用方法 [#a5912b9b] 特定の要素にスタイルを適応 [#u3f765b2] スタイルを継承 [#f923f2e2] テンプレート [#c1ac1a97] データテンプレート [#v289532d] データテンプレートをクラスに適応させる [#x6c68de8] テンプレート内にリソースを適応させる [#e9d96c52] DataTemplateとバインドソース [#o6d284ae] コントロールテンプレート [#j961ba65] トリガー [#pb4f2efd] WPFのスタイルは、スタイルという名前ですがデザインやカラー設定を行うためだけの機能ではありません。 スタイルを定義するにはStyle要素を使用します。Style要素内ではコンポーネントのプロパティ値の設定やデータのプロパティ値の設定ができます。 データテンプレートでは再利用可能なデータバインディングを持ったスタイルを定義します。 コントロールテンプレートでは既存のコントロールのUIデザインを定義できます。 スタイルの使用方法 スタイルはXAMLのResourcesに記述します。 Style.TargetType属性の指定し、XAMLデザイナがSetter要素のPropertyの値を検証するためにも使用します。 Setter要素の値はValue属性に記述することもできますし、次のようにプロパティ要素として記述することもできます。 Setter Property="PropertyA" Setter.Value プロパティ要素 /Setter.Value /Setter 次のコードはXAML内のすべてのTextBlock要素にスタイルが適応されます。 Window.Resources Style TargetType="TextBlock" Setter Property="HorizontalAlignment" Value="Center" / Setter Property="FontSize" Value="14" / Setter Property="FontFamily" Setter.Value Comic Sans MS /Setter.Value /Setter /Style /Window.Resources Grid TextBlock Text="ようこそ。" / TextBlock Text="今日は12月8日です。" / /Grid スタイルだけを先に定義し、各VisualObjectからスタイルを参照したい場合、Style.TargetStyle属性を使用せずにx Key属性を使ってスタイルの定義だけを行います。 Window.Resources Style x Key="MyStyle" Setter Property="TextBlock.HorizontalAlignment" Value="Center" / Setter Property="TextBlock.FontSize" Value="14" / Setter Property="TextBlock.FontFamily" Value="Comic Sans MS" / /Style /Window.Resources 特定の要素にスタイルを適応 Style要素の定義時にx Key要素でスタイルに名前をつけた場合、スタイルが適応されるには明示的にスタイル名を指定する必要があります。 次の例では2つのTextBlockのうち、1番目のTextBlockだけにスタイルが適応されます。 Window.Resources Style x Key="MyStyle" TargetType="TextBlock" Setter Property="HorizontalAlignment" Value="Center" / Setter Property="FontSize" Value="14" / Setter Property="FontFamily" Value="Comic Sans MS" / /Style /Window.Resources Grid TextBlock Text="ようこそ。" Style="{StaticResource MyStyle}" / TextBlock Text="今日は12月8日です。" / /Grid スタイルを継承 Style.BaseOn属性を使用してスタイルを継承し、そこから設定済みプロパティの再設定やプロパティの追加が行えます。 Window.Resources Style TargetType="TextBlock" Setter Property="FontSize" Value="20"/ /Style Style x Key="MyColorStyle" TargetType="TextBlock" BasedOn="{StaticResource {x Type TextBlock} }" Setter Property="Foreground" Value="#FFC13B3B" / /Style /Window.Resources Grid StackPanel Height="100" HorizontalAlignment="Left" Name="stackPanel1" VerticalAlignment="Top" Width="200" TextBlock Height="23" Name="textBlock2" Text="TextBlock" / TextBlock Height="70" Name="textBlock1" Text="よだー" Style="{StaticResource MyColorStyle}"/ /StackPanel /Grid MyColorStyleは既存のTextBlockのスタイルを継承しています。 テンプレート データテンプレート コントロールテンプレート それぞれUIの描画スタイルを設定する手法で、再利用可能なことからテンプレートと呼ばれている。 データテンプレートとは主にコレクションをアイテムとして表示するコントロール(ListBox、ListView、TreeView、DataGrid、その他)で、そのアイテムを描画するためのUIを定義したものです。 コントロールテンプレートとはUIの描画そのものを再定義するものです。Buttonコントロールは1つのコントロールに見えますが内部ではGridやTextBlockを組み合わせて1つのコントロールとして描画しています。 データテンプレート VisualObjectを持つスタイルをデータテンプレートと呼びます。 データテンプレートではデータを表示する為のオブジェクト要素構造をテンプレート化し、UIデザインとデータの両方の再利用を実現できます。 テンプレート化したオブジェクト要素構造は、バインディングによって動的に表示内容を変更するように設計します。 次のサンプルでは、ListBoxに設定したデータソースの要素を描画する際に、各要素を描画するためのテンプレートを定義しています。 ListBox Width="400" Margin="10" ItemsSource="{Binding Source={StaticResource myTodoList} }" ListBox.ItemTemplate DataTemplate StackPanel TextBlock Text="{Binding Path=TaskName}" / TextBlock Text="{Binding Path=Description}"/ TextBlock Text="{Binding Path=Priority}"/ /StackPanel /DataTemplate /ListBox.ItemTemplate /ListBox データテンプレートはリソースとして定義できます。次のように予めリソースとして定義しておきx Key属性で指定した名前を定義しておけば、データテンプレートの再利用が可能です。 ListBox.ItemTemplateへはStaticResourceを使用してリソースを呼び出します。 Window xmlns local="clr-namespace my" Window.Resources ObjectDataProvider x Key="myTodoList" ObjectType="{x Type local Tasks}"/ DataTemplate x Key="myTemplate" StackPanel TextBlock Text="{Binding Path=TaskName}" / TextBlock Text="{Binding Path=Description}"/ TextBlock Text="{Binding Path=Priority}"/ /StackPanel /DataTemplate /Window.Resources !-- リソースに定義した「myTemplate」をデータテンプレートに使用する -- ListBox Width="400" Margin="10" ItemsSource="{Binding Source={StaticResource myTodoList} }" ItemTemplate="{StaticResource myTemplate" / /Window namespace my { public class Tasks ObservableCollection Task { public Tasks() { this.Add(new Task{TaskName="テレビを見る", Description="水戸黄門", Priority=3}); this.Add(new Task{TaskName="電話", Description="佐藤さんに電話", Priority=10}); this.Add(new Task{TaskName="勉強", Description="C#の勉強に明け暮れる", Priority=5}); } } public class Task { public string TaskName { get; set; } puiblic string Description { get; set; } public int Priority { get; set; } } } データテンプレートをクラスに適応させる DataTemplate.DateType を使用すると特定のオブジェクトすべてにデータテンプレートを適用することができます。 この仕組みは 非常に重要 で、任意のC#コードで記述されたクラスに対してXAMLによるUIのデザインを設定できます。 次のサンプルではListBox.ItemTemplateへデータテンプレートの設定を行っていません。しかし、正常に動作します。 これはListBoxがTaskオブジェクトを表示する際に、DataTemplateによって設定されたデータテンプレートが使用されている為です。 Window xmlns local="clr-namespace my" Window.Resources ObjectDataProvider x Key="myTodoList" ObjectType="{x Type local Tasks}"/ DataTemplate DataType="{x Type local Task}" StackPanel TextBlock Text="{Binding Path=TaskName}" / TextBlock Text="{Binding Path=Description}"/ TextBlock Text="{Binding Path=Priority}"/ /StackPanel /DataTemplate /Window.Resources ListBox Width="400" Margin="10" ItemsSource="{Binding Source={StaticResource myTodoList} }" / /Window テンプレート内にリソースを適応させる ComboBoxなどアイテムソースを受け取るコントロールでは、表示させるアイテムをItemsSourceプロパティなどに設定します。 通常はItemsSourceプロパティにはバインディングやリソースを行って項目を指定します。 しかし、データテンプレート内でバインディングを指定する場合には注意が必要です。 バインディングを使用する場合、バインドソースはデータテンプレートに与えられたアイテムになります。(ItemsSourceに設定されたコレクションの各要素がバインドソースとなる) データテンプレート内ですべてのComboBoxに同じ選択肢を表示したい場合には StaticResourceマークアップ拡張 を使用します。 Window.Resources src MyList x Key="myList" / col ArrayList x Key="MyDataSource" sys DateTime 1/2/2003 5 00 00 /sys DateTime sys DateTime 4/5/2006 13 13 13 /sys DateTime sys DateTime 7/8/2009 23 59 59 /sys DateTime /col ArrayList /Window.Resources Grid ListView ItemsSource="{StaticResource MyDataSource}" ListView.View GridView GridViewColumn Header="月" DisplayMemberBinding="{Binding Month}" / GridViewColumn Header="日" DisplayMemberBinding="{Binding Day}" / GridViewColumn Header="日付" DisplayMemberBinding="{Binding DayOfWeek}"/ GridViewColumn GridViewColumn.Header TextBlock Text="何か選択" / /GridViewColumn.Header GridViewColumn.CellTemplate DataTemplate ComboBox Name="comboBox1" Width="100" ItemsSource="{StaticResource ResourceKey=myList}" / /DataTemplate /GridViewColumn.CellTemplate /GridView /ListView.View /ListView /Grid class MyList List string { public MyList() { this.Add("日本"); this.Add("韓国"); this.Add("北朝鮮"); this.Add("中国"); this.Add("台湾"); this.Add("フィリピン"); this.Add("タイ"); this.Add("ベトナム"); } } DataTemplateとバインドソース ContentPresenter Name="stp1" Content="WPFは複雑" Grid.Row="1" Grid.Column="1" Height="22" Margin="9,0,0,0" ContentPresenter.ContentTemplate DataTemplate TextBlock Text="{Binding}" / /DataTemplate /ContentPresenter.ContentTemplate /ContentPresenter 親要素のContentが参照される この例では、TextBlockは「WPFは複雑」と表示されます。 理由は純粋に、ContentプロパティがInhert属性のプロパティなので、ContentPresenterがテンプレートを使ってビジュアルツリーを構築する際に、TextBlock.ContentもContentPresenter.Contentを参照します。 コントロールテンプレート コントロールテンプレートではコントロールの構造と外観を定義します。 スタイルとしてコントロールテンプレートを適応することで、コントロールの構造や外観を再定義することができます。 コントロールテンプレートはControlクラスを継承した多くのコントロールに対して適応できます。 参考 MSDN コントロールテンプレートを適応するというのは、そのコントロールのビジュアルツリーを書き換えることを意味します。 ただし、コントロールのビジュアルツリーの一部だけを書き換えることはできません。 カスタムコントロールテンプレート例 タブ トリガー プロパティの値を判断し、動的に任意のプロパティ値を設定することができる。 if構文と違い、判断するデータソースや設定可能なデータソースは限られている。 データテンプレートで使用する場合は、そのデータがデータソースとなる。(ItemsSource属性を持つComboBoxやListBoxの場合、各要素をデータテンプレートを使って表示する際の各要素がデータソースとなる) よって、プログラマが自由なデータソースを指定し、その値を動的に評価して処理を分岐するといったif構文のような処理は行えない。